﻿using System;
using System.Collections.Generic;
using System.Collections;
using UnityEngine;

namespace ScriptProject
{

    public class MyException : Exception
    {

    }

    public class TestCLRBinding
    {
        static protected Transform _objTransform;
        static protected Vector3 _pos;

        static protected float _elapsedTime;

        static protected GameObject _template;

        public static void Init()
        {
            //CLRBindingTestClass.DoSomeTest(1, 2);

            _template = Resources.Load("Cube") as GameObject;
            _objTransform = UnityEngine.Object.Instantiate(_template).transform;

            _objTransform.transform.position = new Vector3(-6f, 0, 0);
            _pos = _objTransform.localPosition;

            Debug.Log("Object: " + _objTransform);

            var co = _coroutine(10);

            while(co.MoveNext())
            {
                var current = co.Current;
                Debug.Log(current);
            }

            //MyException aa = new MyException();

        }

        public static void RunTest()
        {
            for (int i = 0; i < 1; i++)  
            {
                _pos.x += 0.000003f;
                //_pos += Vector3.one * 0.000003f;
                _objTransform.localPosition = _pos;
            }
        }

        public static IEnumerator _coroutine(int number)
        {
            for (int i = 0; i < number; i++) 
            {
                yield return i;
            }
        }
    }
}
